# # 方式一：
# # ('one', 1), ('two', 2), ('three', 3)
# # (('one', 1), ('two', 2), ('three', 3))
# dic = dict((('one', 1), ('two', 2), ('three', 3)))
# print(dic)  # {'one': 1, 'two': 2, 'three': 3}

# # 方式二：
# dic = dict(one=1, two=2, three=3, name='坚果')
# print(dic)


# # 方式三：
# # dic = dict({'one': 1, 'two': 2, 'three': 3})
# dic = {'one': 1, 'two': 2, 'three': 3}
# print(dic)

# # 字典的嵌套
# dic = {
#     'name': '汪峰',
#     'age': 48,
#     'wife': [{'name': '国际章', 'age': 38},],
#     'children': {'girl_first': '小苹果','girl_second': '小怡','girl_three': '顶顶'}
# }
# print(dic)


# # 获取字典中的值
# dic = {'name': '坚果', 'sex': '男', 'age': 18}
# # print(dic['name'])
# # print(dic['abc'])
# # print(dic.get('name'))
# print(dic.get('abc'))

# 修改字典某个元素
dic = {'name': '坚果', 'sex': '男', 'age': 18}
# dic['age'] = 20
# print(dic)

# # 同时有多个数据实现修改
# info1 = {'name':"郭然然", "id":"ms230", "adress":"上海"}
# info2 = {'name':"郭然然2", "pre_xz":"15k", "bre_xz":"20k", "gs":"zjtd"}
# info1.update(info2)
# print(info1)
# del info1['id']
# print(info1)
# del info1
# print(info1)


# 常用函数
info = {'a': 1, 'b': 2, 'hhh': '你想要删除的值'}
# print(len(info))	# 获取字典长度
# info_str = str(info)
# print(info_str)	# 字典转化为字符串
# print(info_str[0])
# print(info[0])
# info_values = info.values()  # 获取字典所有的value
# print(info_values)
# print(info.popitem())	# 删除字典中最后的一对键值对，并返回key和value，以元组的形式(key, value)
# print(info)
# print(info.pop('b', '查不到'))	# 根据给定的key进行删除
# print(info)
# print(info.keys())	# keys列出所有键
# print(info.items())	# 同时获取key,value的值
# print(info.get('age'))	# 取出指定键的值，没有的元素不会抛异常
# print({}.fromkeys('name', 100))	# 创建字典  {'n': 100, 'a': 100, 'm': 100, 'e': 100}
# a = info.setdefault('sex', 'M')
# print(a)	# 类似get方法，获取元素的值，但是当key不存在，则添加key并，默认为None，否则取默认值
# print(info)
# print(info.copy())	# 复制字典，浅copy
info.clear()	# 清空内容
print(info)